<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('仓库货物列表')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
         <div class="col-sm-12" style="font-weight: bold; font-size: 16px;">仓库货物管理</div>
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>商品ID：</label>
                                <input type="text" name="goodsId"/>
                            </li>
                            <li>
                                <label>商品名称：</label>
                                <input type="text" name="goodsName"/>
                            </li>
                            <li>
                                <label>生产厂家：</label>
                                <select name="manufacturer" id="manufacturer" class="form-control" th:with="type=${@dict.getType('goods_manufacturer')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>商品类型：</label>
                                <select name="goodsType" id="goodsType" class="form-control" th:with="type=${@dict.getType('goods_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>品牌：</label>
                                <select name="brand" id="brand" class="form-control" th:with="type=${@dict.getType('goods_brand')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>供应商：</label>
                                <select name="supplier" id="supplier" class="form-control" th:with="type=${@dict.getType('goods_supplier')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>单价：</label>
                                <input type="text" name="goodsPrice"/>
                            </li>
                            <li>
                                <label>数量：</label>
                                <input type="text" name="goodsMount"/>
                            </li>
                            <li>
                                <label>位置：</label>
                                <select name="goodsPosition" id="goodsPosition" class="form-control" th:with="type=${@dict.getType('goods_goodsPosition')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:list:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="business:list:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="business:list:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="business:list:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
     <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('business:list:edit')}]];
        var removeFlag = [[${@permission.hasPermi('business:list:remove')}]];
        var addFlag = [[${@permission.hasPermi('business:order:add')}]];
        var prefix = ctx + "business/list";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "仓库货物",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'goodsId',
                    title: '商品ID'
                },
                {
                    field: 'goodsName',
                    title: '商品名称'
                },
                {
                    field: 'manufacturer',
                    title: '生产厂家'
                },
                {
                    field: 'goodsType',
                    title: '商品类型'
                },
                {
                    field: 'brand',
                    title: '品牌'
                },
                {
                    field: 'supplier',
                    title: '供应商'
                },
                {
                    field: 'goodsPrice',
                    title: '商品价格',
                    visible: false
                },
                {
                    field: 'goodsMount',
                    title: '数量'
                },
                {
                    field: 'goodsPosition',
                    title: '位置'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'updateTime',
                    title: '修改时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a style="margin-left: 3px;" class="btn btn-warning btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="orderAdd(\'' + row.goodsId + '\')"><i class="fa fa-level-up"></i>销售</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function orderAdd(goodsId){
            var orderAddUrl = "/business/order" + "/add?goodsId="+goodsId;
            $.modal.open("创建销售单", orderAddUrl);
        }

        function resetPre() {
            $("#formId")[0].reset();
            $("#select2-manufacturer-container").html("所有")
            $("#select2-goodsType-container").html("所有")
            $("#select2-brand-container").html("所有")
            $("#select2-supplier-container").html("所有")
            $("#select2-goodsPosition-container").html("所有")
            $.table.search('formId', 'bootstrap-table');
        }
    </script>
</body>
</html>